Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Latte] Add tryRequestQuota for SuspendingRatelimit #14

Merged
merged 2 commits into from
Oct 13, 2024

Conversation

ShindouMihou
Copy link
Member

This pull request adds tryRequestQuota for SuspendingRatelimit to enable a wider range of applications, such as rate-limiting specific commands. Unlike requestQuota, tryRequestQuota doesn't wait for the quota to be available, but instead, returns a pair of a Boolean (canProceed) and a nullable Long (remainingWaitTime) which can be useful for such applications.

  • This pull request has been tested to work.

@ShindouMihou ShindouMihou self-assigned this Aug 4, 2024
Comment on lines +56 to +57
check(remainingQuota > 0)
remainingQuota--
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given thas these two lines are the same in the new and the old method, I think we should also move them to the common function and perhaps rename it to something a bit more generic then, like calculateQuota. Otherwise LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow, moving these two lines to a common function would result in the function misbehaving (failing), so yeah, I think we can just keep it like that, given that it's just two lines. What do you think? (I think it's because of the check that's failing).

@wasdennnoch wasdennnoch changed the title [Latte] Adds tryRequestQuota for SuspendingRatelimit [Latte] Add tryRequestQuota for SuspendingRatelimit Oct 13, 2024
@wasdennnoch wasdennnoch merged commit 88f1fa2 into main Oct 13, 2024
1 check passed
@wasdennnoch wasdennnoch deleted the miu/feat/suspending-ratelimit-try-request-quota branch October 13, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants